package com.example.my_project.auto_v2.pojo;

import java.util.ArrayList;

/**
 * @Author: chenbo
 * @Description:
 *              code : 0 正常
 *                     -1 业务异常
 *                     -200 数据库异常
 *                     -500 网络异常
 *                     -1000 其他异常
 * @Date: Created in 17:54 2018/7/25
 * @Modified By:
 */
public class JsonResult {

    private Integer code;
    private String msg;
    private Object value;

    public static JsonResult pass(Object value ){
        return new JsonResult( value );
    }

    public static JsonResult pass(String msg , Object value ){
        return new JsonResult( 0 , msg , value );
    }

    public static JsonResult pass(String msg ){
        return new JsonResult(0,msg,new ArrayList<>());
    }

    public static JsonResult errorMsg(String msg ){
        return new JsonResult(-1,msg,new ArrayList<>());
    }

    public static JsonResult exceptionMsg(String msg , Object value){
        return new JsonResult( -10000 , msg ,value);
    }

    public JsonResult(Integer code, String msg, Object value) {
        this.code = code;
        this.msg = msg;
        this.value = value;
    }

    public JsonResult(Object value) {
        this.code = 0;
        this.msg = "成功！";
        this.value = value;
    }

    public JsonResult() {
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getValue() {
        return value;
    }

    public void setValue(Object value) {
        this.value = value;
    }
}
